//
//  main.c
//  C_2 存储器和指针
//
//  Created by Robin on 16/3/16.
//  Copyright © 2016年 cnbm. All rights reserved.
//

#include <stdio.h>


char * exchange_card_wrong (char *cards);
char *exchange_card (char cards[]);


int main(int argc, const char * argv[]) {
    // insert code here...
    //printf("Hello, World!\n");
    
    //const char *card_words = "JQK"; 修饰一个常量,让它不可更改
    
    //card_words[0] = 's';
    
    //exchange_card_wrong(cards);
    
    char masked_raider[] = "alive";
    char *Jimmy = masked_raider;
    
    printf("masked_raider is %s Jimmy is %s\n",masked_raider,Jimmy);
    
    masked_raider[0] = 'D';
    masked_raider[1] = 'E';
    masked_raider[2] = 'A';
    masked_raider[3] = 'D';
    masked_raider[4] = '!';
    
    printf("masked_raider is %s Jimmy is %s\n",masked_raider,Jimmy);
    
    char cards[] = "JQK";
    
    char *card = exchange_card(cards);
    
    puts(card);
    
   // puts(cards);
    
    return 0;
}

char * exchange_card_wrong (char *cards){
    
    //char *cards = "JQK";
    char a_card = cards[2];
    
    cards[2] = cards[1];
    cards[1] = cards[0];
    cards[0] = cards[2];
    cards[2] = cards[1];
    cards[1] = a_card;
    
    return cards;
}

char *exchange_card (char cards[]){
    
    char a_card = cards[2];
    
    cards[2] = cards[1];
    cards[1] = cards[0];
    cards[0] = cards[2];
    cards[2] = cards[1];
    cards[1] = a_card;
    
    return cards;

}
